<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="time"></div>
    <script>
        setInterval("getTime()", 1000);

        function getTime() {
            var data = new Date(); //获取当前系统的时间
            var year = data.getFullYear(); //年
            var month = data.getMonth() + 1; //月  从0开始
            var day = data.getDate(); //日
            let week = data.getDay(); //星期几 0：星期天
            var hour = data.getHours(); //时
            var min = data.getMinutes(); //分
            var second = data.getSeconds(); //秒
            let weekStr = '';
            switch (week) {
                case 0:
                    weekStr = "星期天";
                    break;
                case 1:
                    weekStr = "星期一";
                    break;
                case 2:
                    weekStr = "星期二";
                    break;
                case 3:
                    weekStr = "星期三";
                    break;
                case 4:
                    weekStr = "星期四";
                    break;
                case 5:
                    weekStr = "星期五";
                    break;
                case 6:
                    weekStr = "星期六";
                    break;
            }
            var currentTime = `${year}年${month}月${day}日 ${hour}:${min}:${second} ${weekStr}`;
            document.getElementById("time").innerText = currentTime;

        }
    </script>
</body>

</html>